package cn.edu.scau.cmi.luochenghao.chapter10;

import java.io.*;

class FileAccept implements FilenameFilter{
	private String extendName;
	public void setExtendName(String s) {
		extendName = "."+s;
		return;
	}
	
	public boolean accept(File dir,String name) {
		return name.endsWith(extendName);
	}
}

public class Example10_2 {
	public static void main(String args[]) {
		File dir = new File("/Users/luochenghao/git/201725110111_luo_chenghao/201725110111罗铖昊/src/cn/edu/scau/cmi/luochenghao/chapter10");
		FileAccept fileAccept = new FileAccept();
		fileAccept.setExtendName("java");
		String[] fileName = dir.list(fileAccept);
		for (String name : fileName) {
			System.out.println(name);
		}
	}
}
